package models

import (
	"gorm.io/gorm"
)

/*
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `admin_id` int NOT NULL DEFAULT '0' COMMENT '管理员id',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '操作说明',
  `url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作路由',
  `param` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作参数',
  `app_id` int DEFAULT '0' COMMENT '数据归属',
*/
// AuthHandleLog 对应数据库表 auth_group
type AuthHandleLog struct {
	gorm.Model
	ID        uint     `gorm:"primaryKey;autoIncrement;comment:主键，自增ID"`
	AdminID   uint     `gorm:"default:0;index:idx_admin_id;comment:管理员ID"`
	Name      string   `gorm:"not null;default:'';comment:操作说明"`
	URL       string   `gorm:"not null;default:'';comment:操作路由"`
	Param     string   `gorm:"comment:操作参数"`
	AppID     int      `gorm:"default:0;comment:数据归属"`
	CreatedAt int64    `gorm:"autoCreateTime;comment:创建时间戳"` // 修改为 int64 类型
	UpdatedAt int64    `gorm:"autoUpdateTime;comment:更新时间戳"` // 修改为 int64 类型
	AuthUser  AuthUser `gorm:"foreignKey:AdminID;references:ID"`
}

type AuthHandleLogList struct {
	ID        uint   `json:"id"`
	AdminID   uint   `json:"admin_id"`
	AdminName string `json:"admin_name"`
	Name      string `json:"name"`
	URL       string `json:"url"`
	Param     string `json:"param"`
	AppID     int    `json:"app_id"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type AuthHandleLogCreate struct {
	AdminID   uint   `json:"admin_id"`
	Name      string `json:"name"`
	URL       string `json:"url"`
	Param     string `json:"param"`
	AppID     int    `json:"app_id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
}

type AuthHandleLogUpdate struct {
	ID      uint   `json:"id"`
	AdminID uint   `json:"admin_id"`
	Name    string `json:"name"`
	URL     string `json:"url"`
	Param   string `json:"param"`
	AppID   int    `json:"app_id"`
}

// TableName 设置表名为
func (AuthHandleLog) TableName() string {
	return "auth_handle_log"
}
